package pck_gui;

import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import pck_pojos.Cls_Encargatura_Permiso;
import pck_utilitarios.Cls_Funciones;
import pck_utilitarios.Cls_InvocaWebService;
import pck_utilitarios.Cls_Parametros;
import pck_utilitarios.Utiles_Panel;
import udprrhh.UDPRRHHView;

/**
 *
 * @author supermiguelon
 */
public class JP_Levantar_Encargaturas extends pck_utilitarios.JP_Modelo {

    long idPermiso;

    /** Creates new form JP_Levantar_Encargaturas */
    public JP_Levantar_Encargaturas() {
        initComponents();
        btnActualizar.setEnabled(Boolean.FALSE);
        btnCancelar.setEnabled(false);
    }

    public void limpiar() {
        Cls_Funciones.limpiarTxtField(txtUnidadCodigo, txtUnidadNombre,
                txtPrincipalDni, txtPrincipalNombre, txtPrincipalCargo,
                txtPrincipalPermiso, txtPrincipalFechaInicio, txtPrincipalFechaFin,
                txtEncargadoDni, txtEncargadoNombres, txtEncargadoCargo);
        btnCancelar.setEnabled(false);
        btnActualizar.setEnabled(false);
    }

    public void obtenerUnidad(String codigo) {
        String[] param = {Cls_Parametros.Map_CODIGO_UNIDAD_ORGANICA, codigo};
        Cls_Encargatura_Permiso encarg = Cls_InvocaWebService.obtenerEncargatura(
                Cls_Funciones.generarHashMapParaSolicitud(param));
        if (encarg != null) {
            idPermiso = encarg.getId_permiso();
            txtUnidadCodigo.setText(encarg.getCodUniOrganizativa());
            txtUnidadNombre.setText(encarg.getNombreUniOrganizativa());
            txtPrincipalDni.setText(encarg.getDniPrincipal());
            txtPrincipalNombre.setText(encarg.getNombrePrincipal());
            txtPrincipalCargo.setText(encarg.getCargoPrincipal());
            txtPrincipalPermiso.setText(encarg.getPermiso());
            txtPrincipalFechaInicio.setText(formatoFecha(encarg.getFechaInicio()));
            txtPrincipalFechaFin.setText(formatoFecha(encarg.getFechaFin()));
            txtEncargadoDni.setText(encarg.getDniEncargado());
            txtEncargadoNombres.setText(encarg.getNombreEncargado());
            txtEncargadoCargo.setText(encarg.getCargoEncargado());
            btnActualizar.setEnabled(Boolean.TRUE);
            btnCancelar.setEnabled(true);
        } else {
            JOptionPane.showMessageDialog(this, "Esta unidad no tiene encargatura",
                    "¡Error", JOptionPane.ERROR_MESSAGE);
        }

    }
    private String formatoFecha(String fecha){
         String[] f = fecha.split("-");
        try{
         return f[2].split(" ")[0]+"/"+f[1]+"/"+f[0];
        }catch(Exception ex){
            return fecha;
        }
    }

    public String actualizar() {
        String[] param = {Cls_Parametros.Map_ID_ENCARGATURA, String.valueOf(idPermiso)};
        String[] param1 = {Cls_Parametros.Map_DNI,txtPrincipalDni.getText()};
        return Cls_InvocaWebService.actualizarEncargatura(Cls_Funciones.generarHashMapParaSolicitud(param,param1));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        paneMain = new javax.swing.JPanel();
        paneUnidad = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtUnidadCodigo = new javax.swing.JTextField();
        txtUnidadNombre = new javax.swing.JTextField();
        btnUnidadBuscar = new javax.swing.JButton();
        paneTrabajador = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        txtPrincipalDni = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtPrincipalNombre = new javax.swing.JTextField();
        txtPrincipalCargo = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtPrincipalPermiso = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtPrincipalFechaInicio = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtPrincipalFechaFin = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        txtEncargadoDni = new javax.swing.JTextField();
        txtEncargadoNombres = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtEncargadoCargo = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        btnActualizar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(JP_Levantar_Encargaturas.class);
        paneMain.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("paneMain.border.title"))); // NOI18N
        paneMain.setName("paneMain"); // NOI18N

        paneUnidad.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("paneUnidad.border.title"))); // NOI18N
        paneUnidad.setName("paneUnidad"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        txtUnidadCodigo.setEditable(false);
        txtUnidadCodigo.setText(resourceMap.getString("txtUnidadCodigo.text")); // NOI18N
        txtUnidadCodigo.setName("txtUnidadCodigo"); // NOI18N

        txtUnidadNombre.setEditable(false);
        txtUnidadNombre.setText(resourceMap.getString("txtUnidadNombre.text")); // NOI18N
        txtUnidadNombre.setName("txtUnidadNombre"); // NOI18N

        btnUnidadBuscar.setText(resourceMap.getString("btnUnidadBuscar.text")); // NOI18N
        btnUnidadBuscar.setName("btnUnidadBuscar"); // NOI18N
        btnUnidadBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUnidadBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paneUnidadLayout = new javax.swing.GroupLayout(paneUnidad);
        paneUnidad.setLayout(paneUnidadLayout);
        paneUnidadLayout.setHorizontalGroup(
            paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneUnidadLayout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(28, 28, 28)
                .addGroup(paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(paneUnidadLayout.createSequentialGroup()
                        .addComponent(txtUnidadCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnUnidadBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(txtUnidadNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        paneUnidadLayout.setVerticalGroup(
            paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneUnidadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtUnidadCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnUnidadBuscar))
                .addGap(18, 18, 18)
                .addGroup(paneUnidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtUnidadNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        paneTrabajador.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("paneTrabajador.border.title"))); // NOI18N
        paneTrabajador.setName("paneTrabajador"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        txtPrincipalDni.setEditable(false);
        txtPrincipalDni.setText(resourceMap.getString("txtPrincipalDni.text")); // NOI18N
        txtPrincipalDni.setName("txtPrincipalDni"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        txtPrincipalNombre.setEditable(false);
        txtPrincipalNombre.setText(resourceMap.getString("txtPrincipalNombre.text")); // NOI18N
        txtPrincipalNombre.setName("txtPrincipalNombre"); // NOI18N

        txtPrincipalCargo.setEditable(false);
        txtPrincipalCargo.setText(resourceMap.getString("txtPrincipalCargo.text")); // NOI18N
        txtPrincipalCargo.setName("txtPrincipalCargo"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        txtPrincipalPermiso.setEditable(false);
        txtPrincipalPermiso.setText(resourceMap.getString("txtPrincipalPermiso.text")); // NOI18N
        txtPrincipalPermiso.setName("txtPrincipalPermiso"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        txtPrincipalFechaInicio.setEditable(false);
        txtPrincipalFechaInicio.setText(resourceMap.getString("txtPrincipalFechaInicio.text")); // NOI18N
        txtPrincipalFechaInicio.setName("txtPrincipalFechaInicio"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        txtPrincipalFechaFin.setEditable(false);
        txtPrincipalFechaFin.setName("txtPrincipalFechaFin"); // NOI18N

        javax.swing.GroupLayout paneTrabajadorLayout = new javax.swing.GroupLayout(paneTrabajador);
        paneTrabajador.setLayout(paneTrabajadorLayout);
        paneTrabajadorLayout.setHorizontalGroup(
            paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneTrabajadorLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(paneTrabajadorLayout.createSequentialGroup()
                        .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addGap(18, 18, 18)
                        .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtPrincipalPermiso, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPrincipalCargo, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPrincipalNombre)
                            .addComponent(txtPrincipalDni, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)))
                    .addGroup(paneTrabajadorLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(txtPrincipalFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(txtPrincipalFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        paneTrabajadorLayout.setVerticalGroup(
            paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneTrabajadorLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrincipalDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrincipalNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrincipalCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrincipalPermiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(paneTrabajadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtPrincipalFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtPrincipalFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel4.border.title"))); // NOI18N
        jPanel4.setName("jPanel4"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        txtEncargadoDni.setEditable(false);
        txtEncargadoDni.setText(resourceMap.getString("txtEncargadoDni.text")); // NOI18N
        txtEncargadoDni.setName("txtEncargadoDni"); // NOI18N

        txtEncargadoNombres.setEditable(false);
        txtEncargadoNombres.setText(resourceMap.getString("txtEncargadoNombres.text")); // NOI18N
        txtEncargadoNombres.setName("txtEncargadoNombres"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        txtEncargadoCargo.setEditable(false);
        txtEncargadoCargo.setText(resourceMap.getString("txtEncargadoCargo.text")); // NOI18N
        txtEncargadoCargo.setName("txtEncargadoCargo"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addGap(22, 22, 22)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(txtEncargadoCargo, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEncargadoNombres, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEncargadoDni, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE))
                .addContainerGap(58, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtEncargadoDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEncargadoNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEncargadoCargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        btnActualizar.setText(resourceMap.getString("btnActualizar.text")); // NOI18N
        btnActualizar.setName("btnActualizar"); // NOI18N
        btnActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarActionPerformed(evt);
            }
        });

        btnCancelar.setText(resourceMap.getString("btnCancelar.text")); // NOI18N
        btnCancelar.setName("btnCancelar"); // NOI18N
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout paneMainLayout = new javax.swing.GroupLayout(paneMain);
        paneMain.setLayout(paneMainLayout);
        paneMainLayout.setHorizontalGroup(
            paneMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneMainLayout.createSequentialGroup()
                .addGroup(paneMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(paneMainLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(paneMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(paneUnidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(paneTrabajador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(paneMainLayout.createSequentialGroup()
                        .addGap(67, 67, 67)
                        .addComponent(btnActualizar)
                        .addGap(85, 85, 85)
                        .addComponent(btnCancelar)))
                .addContainerGap())
        );
        paneMainLayout.setVerticalGroup(
            paneMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(paneMainLayout.createSequentialGroup()
                .addComponent(paneUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(paneTrabajador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(paneMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnActualizar)
                    .addComponent(btnCancelar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(paneMain, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(paneMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnUnidadBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUnidadBuscarActionPerformed
        JInternalFrame jif_trabajador_Buscar;
        JP_Unidad_Organica_Buscar panel = new JP_Unidad_Organica_Buscar(0);
        jif_trabajador_Buscar = Utiles_Panel.creaVentanaInternaModal((UDPRRHHView) this.getRef(), panel, "Busca de Trabajadores");
        panel.setPadre(Utiles_Panel.TIPO_JINTERNALFRAME, jif_trabajador_Buscar);
        panel.setRefDep(this);
    }//GEN-LAST:event_btnUnidadBuscarActionPerformed

    private void btnActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarActionPerformed
        int opcion = JOptionPane.showConfirmDialog(this, "¿Desea levantar la "
                + "encargatura?", "Confirmación", JOptionPane.YES_NO_OPTION);
        switch (opcion) {
            case JOptionPane.YES_OPTION:
                JOptionPane.showMessageDialog(this, this.actualizar());
                limpiar();
                break;
            case JOptionPane.NO_OPTION:
                JOptionPane.showMessageDialog(this, "Actualización cancelada "
                        + "por el usuario.", "Aviso", JOptionPane.INFORMATION_MESSAGE);
                break;
        }
    }//GEN-LAST:event_btnActualizarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        limpiar();
    }//GEN-LAST:event_btnCancelarActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnUnidadBuscar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel paneMain;
    private javax.swing.JPanel paneTrabajador;
    private javax.swing.JPanel paneUnidad;
    private javax.swing.JTextField txtEncargadoCargo;
    private javax.swing.JTextField txtEncargadoDni;
    private javax.swing.JTextField txtEncargadoNombres;
    private javax.swing.JTextField txtPrincipalCargo;
    private javax.swing.JTextField txtPrincipalDni;
    private javax.swing.JTextField txtPrincipalFechaFin;
    private javax.swing.JTextField txtPrincipalFechaInicio;
    private javax.swing.JTextField txtPrincipalNombre;
    private javax.swing.JTextField txtPrincipalPermiso;
    private javax.swing.JTextField txtUnidadCodigo;
    private javax.swing.JTextField txtUnidadNombre;
    // End of variables declaration//GEN-END:variables
}
